package com.db.williamchart.renderer.executor;

import com.db.williamchart.data.Frame;
import ohos.utils.Pair;

import java.util.ArrayList;
import java.util.List;

public class DefineVerticalTouchableFrames {

    public List<Frame> invoke(Frame innerFrame, List<Pair<Float,Float>> datapointsCoordinates){

        float halfDistanceBetweenDataPoints = (innerFrame.getRight() - innerFrame.getLeft() - (datapointsCoordinates.size() + 1)) /
                datapointsCoordinates.size() / 2;
        List<Frame> frames = new ArrayList<>();
        for (Pair<Float,Float> pair : datapointsCoordinates){
            frames.add(new Frame(pair.f - halfDistanceBetweenDataPoints,
                    innerFrame.getTop(),
                    pair.f + halfDistanceBetweenDataPoints,
                    innerFrame.getBottom()));
        }
        return frames;
    }
}
